# ---- Caption and Heading of File ---------------------------------------------
#                                                                              #
#        Replication script for creating Figure 2.                             #
#        Not called directly, is a subroutine.                                 #
#                                                                              #
################################################################################

  
  
  par(mfrow=c(1,1), mar=c(0, 0, 0, 0), family="serif", mgp=c(3, .1, 0), omi=c(0,0,0,0))
  
  n_jurors <- 6
  plot(x="", y="", ylim=c(-1,.5), xlim=c(0-.5,n_jurors+.5), asp=1, axes=F, xlab="", ylab="")
  # plot the nodes
  points(x=0:3, y=rep(0, 3+1), pch=21, bg="gray", cex=5, col="black")
  points(x=5:6, y=rep(0, 2), pch=21, bg="gray", cex=5, col="black")
  points(x=c(3.9, 4, 4.1), y=rep(0, 3), pch=21, bg="gray20", cex=.8, col="black")
  text(x=0:3, y=rep(0, 3+1), labels = 0:3)
  text(x=5:6, y=rep(0, 2), labels = c("n-1", "n"))
  # up one
  arrows(x0 = (1:5)+.30, x1 = (2:6)-.30, y0 = .10, y1 = .10, length = .05)
  p1 <- expression((p[1])^ 2)
  p2 <- expression((p[2])^ 2)
  p3 <- expression((p[3])^ 2)
  pn_2 <- expression((p[n-2])^ 2)
  pn_1 <- expression((p[n-1])^ 2)
  text(x = (1:5)+.5, y = .10, pos=3, 
       label=c(p1,p2,p3,pn_2,pn_1), cex=.8)
  # down one
  arrows(x0 = (1:5)-.30, x1 = (0:4)+.30, y0 = -.10, y1 = -.10, length = .05)
  p1 <- expression((1-p[1])^ 2)
  p2 <- expression((1-p[2])^ 2)
  p3 <- expression((1-p[3])^ 2)
  pn_2 <- expression((1-p[4])^ 2)
  pn_1 <- expression((1-p[n-1])^ 2)
  text(x = (0:4)+.5, y = -.10, pos=1, label=c(p1,p2,p3,pn_2,pn_1), cex=.8)
  # stays same
  segments(x0 = (0:3)-.05, x1 = (0:3)-.05, y0 = -.60, y1 = -.30)
  arrows(x0 = (0:3)+.05, x1 = (0:3)+.05, y0 = -.60, y1 = -.30, length = .05)
  segments(x0 = (0:3)-.05, x1 = (0:3)+.05, y0 = -.60, y1 = -.60)
  segments(x0 = (5:6)-.05, x1 = (5:6)-.05, y0 = -.60, y1 = -.30)
  arrows(x0 = (5:6)+.05, x1 = (5:6)+.05, y0 = -.60, y1 = -.30, length = .05)
  segments(x0 = (5:6)-.05, x1 = (5:6)+.05, y0 = -.60, y1 = -.60)
  p1 <- expression(2* p[1]* (1-p[1]) ) 
  p2 <- expression(2* p[2]* (1-p[2]) ) 
  p3 <- expression(2* p[3]* (1-p[3]) ) 
  pn_1 <- expression(2* p[n-1]* (1-p[n-1]) ) 
  text(x = c(0:3,5:6), y = -.60, pos=1, 
       label=c("1.00",p1,p2,p3,pn_1, "1.00"), cex=.8)



